﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TAdMagazineIssue.aspx.cs" Inherits="Admagazine_TAdMagazineIssue" %>

<%@ Register Assembly="GMDatePicker" Namespace="GrayMatterSoft" TagPrefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
     <title>无标题页</title>
 <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
    <script src="../js/jquery0905.js" type="text/javascript"></script>
    <script src="../js/jqModal.js" type="text/javascript"></script>  
    <script src="../js/ajaxfileupload.js" type="text/javascript"></script>  
    <script language="JScript" src="../js/myCheck.js"></script>
    <link href="../css/pagebox.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" language="javascript">  
  
    
    function NotCharacter(str,name)
    {
        var vstr =/^[A-Za-z0-9]+$/;
        if(!vstr.test(str)){
        alert(name+"必须是字母或数字!");
        return false;}
    }
    
    function chk() 
	{
        $('#txtIssueCode').val($.trim( $('#txtIssueCode').val()));
        $('#txIssueNo').val($.trim( $('#txIssueNo').val()));
        $('#txtIssuePages').val($.trim( $('#txtIssuePages').val()));
        $('#txtPrice').val($.trim( $('#txtPrice').val()));
        $('#txtCover').val($.trim( $('#txtCover').val()));
        $('#txtCoverTitle').val($.trim( $('#txtCoverTitle').val()));
        $('#txtPrintQty').val($.trim( $('#txtPrintQty').val()));
        $('#txtNotice').val($.trim( $('#txtNotice').val()));
       
       
		if(CheckText(form1.txtIssueCode,"编码",20)==false) return false;
		if(NotCharacter(form1.txtIssueCode.value,"编码")==false) return false;
		if(CheckText(form1.txIssueNo,"期号",20)==false) return false;
		if(CheckNum2(form1.txtIssuePages,"总页数")==false) return false;
		if(CheckNum2(form1.txtPrice,"销售价")==false) return false;
		if(form1.txtCover.value==""){ alert('请上传封面图!'); form1.txtCover.focus(); return false;}
		if(CheckText(form1.txtCoverTitle,"封面标题",200)==false) return false;
		if(CheckNum2(form1.txtPrintQty,"印刷数量")==false) return false;
		
		

		return true;
	}
   
    
    $().ready(function() {
        $('#divInput').jqm({modal: true,trigger: '#btnAdd'});
        
    });
    var opration="";
   
    function showdiv()
    {
        $('#divInput').jqmShow(); 
    }
    function inputbind(strid)
    {
        $('#tdtitle').text("修改");
        var urlstring="tadmagazineissue.aspx";
            $.ajax({
            url:urlstring,
            type:'post',
            dataType:'html',
            data:'&opration=bind&id='+ strid ,
            beforeSend:function()
            {
               
            },
            error:function()
            {
               
            },
            success: function(msg)
            {
                var val=msg.split(',');
                $('#txtIssueCode').val(val[0]);
                
                $('#txIssueNo').val(val[1]);
                $('#gmdpDate_dateLabel').text(val[2]);
                $('#txtIssuePages').val(val[3]);
                $('#txtPrice').val(val[4]);
                $('#txtCover').val(val[5]);
                $('#txtCoverTitle').val(val[6]);
                $('#txtPrintQty').val(val[7]);
                $('#txtNotice').val(val[8]);
                $('#imgpreview').attr('src',val[5]);
                
                $('#divInput').jqmShow(); 
                opration='edit';
                $('#txtIssueCode').attr('disabled',true);
                
            }
            });
    }
    
    function save()
    {
        
        if(!chk())return;
         if(opration=="")
            opration="save";
            var urlstring="tadmagazineissue.aspx";
            $.ajax({
            url:urlstring,
            type:'post',
            dataType:'html',
            data:'&opration='+opration+'&code='+ escape($('#txtIssueCode').val())+'&no='+ escape($('#txIssueNo').val())+'&date='+ escape($('#gmdpDate_dateLabel').text())+'&pages='+ escape($('#txtIssuePages').val())+'&price='+ escape($('#txtPrice').val())+'&cover='+ escape($('#txtCover').val())+'&title='+ escape($('#txtCoverTitle').val())+'&qty='+ escape($('#txtPrintQty').val())+'&notice='+ escape($('#txtNotice').val())+ "&type=" + $('#spanlab').text() ,
            beforeSend:function()
            {
            },
            error:function()
            {
               
            },
            success: function(msg)
            {
                if(msg=="")
                {
                    $('#divInput').jqmHide(); 
                    opration='';
                    $('#txtIssueCode').attr('disabled',false);
                    location.href="tadmagazineissue.aspx?typeid=" + $('#spanlab').text() ;
                }
                else
                {
                    alert(msg);
                }
            }
            });
    }
    
   function del(strid)
    {
        var urlstring="tadmagazineissue.aspx";
            $.ajax({
            url:urlstring,
            type:'post',
            dataType:'html',
            data:'&opration=del&id='+ strid ,
            beforeSend:function()
            {
               
            },
            error:function()
            {
               
            },
            success: function(msg)
            {
                opration='edit';
                $('#txtIssueCode').attr('disabled',true);
                location.href="tadmagazineissue.aspx?typeid=" + $('#spanlab').text();
            }
            });
    }
    function clearin()
    {
        
        $(".in").val('');
        $('#chkShow').attr('checked',true);
        $('#tdtitle').text("添加");
    }
    function fileupload()
    {
        
        if(!checkfile())
            return;
        $('#imgpreview').attr('src','images/loading.gif');
        $.ajaxFileUpload
		(
			{
				url:'imgfileupload.aspx',
				secureuri:false,
				fileElementId:'fileCover',
				dataType: 'json',
				success: function (data, status)
				{
					if(typeof(data.error) != 'undefined')
					{
						if(data.error != '')
						{
							alert(data.error);
						}
						else
						{
							$('#txtCover').val(data.msg);
							$('#imgpreview').attr('src',data.msg);
						}
					}
				},
				error: function (data, status, e)
				{
					alert(e);
				}
			}
		)
		
		return false;
    }
    function checkfile()
    {
        var ext=$('#fileCover').val().split(".")[$('#fileCover').val().split(".").length-1];
        var notstr="gif,png,jpg,jpeg,bmp";
        if(notstr.indexOf(ext) ==-1)
        {
            alert("只能上传图片文件!");
            return false;
        }
        return true;
    }
    </script>
</head>
<body >
    <form id="form1" runat="server">
     <div id="divInput" class="jqmWindow" style="display:none; left: 63%; width: 332px; top: 14%;">
        <table width='100%' style ="background-color:#0075b0">
            <tr>
                <td align="left" id='tdtitle' style="font-size:12px;color:White"></td><td align="right" ><asp:ImageButton ID="btnPanel2Cancel" runat="server" ImageUrl="~/adsetup/images/close.png" CausesValidation='false' OnClick="btnPanel2Cancel_Click" /></td>
            </tr>
        </table>
        <br />
        <table width='100%'>
            <tr>
                <td align="right" style="width: 110px" >编码:</td>
                <td><asp:TextBox CssClass='in' ID='txtIssueCode' runat="server" ></asp:TextBox></td>
            </tr>
            <tr>
                <td align="right" style="width: 110px">期号:</td>
                <td><asp:TextBox CssClass='in' ID='txIssueNo' runat="server" ></asp:TextBox></td>
            </tr>
            <tr>
                <td align="right" style="width: 110px">出版日期:</td>
                <td>
                    <cc1:GMDatePicker ID="gmdpDate" runat="server" DisplayMode="Label" ShowNoneButton="False">
                    </cc1:GMDatePicker>
                </td>
            </tr>
            <tr>
                <td align="right" style="width: 110px">总页数:</td>
                <td><asp:TextBox CssClass='in' ID='txtIssuePages' runat="server" ></asp:TextBox></td>
            </tr>
             <tr>
                <td align="right" style="width: 110px">销售价:</td>
                <td><asp:TextBox CssClass='in' ID='txtPrice' runat="server" ></asp:TextBox></td>
            </tr>
            <tr>
                <td align="right" style="width: 110px">封面图:</td>
                <td><input type="hidden" class='in' id='txtCover' runat="server" />
                    <input type="file" id='fileCover' name="fileCover" /><input type="button" id="btnUpload" value='上传' onclick ='return fileupload();' />
                </td>
            </tr>
               <tr>
                <td align="right" style="width: 110px"></td>
                <td ><img id='imgpreview'  height='100' width='80' /></td>
            </tr>
            <tr>
                <td align="right" style="width: 110px">封面标题:</td>
                <td><asp:TextBox CssClass='in' ID='txtCoverTitle' runat="server" ></asp:TextBox></td>
            </tr>
            <tr>
                <td align="right" style="width: 110px">印刷数量:</td>
                <td><asp:TextBox CssClass='in' ID='txtPrintQty' runat="server" ></asp:TextBox></td>
            </tr>
            <tr>
                <td align="right" style="width: 110px">备注:</td>
                <td><asp:TextBox CssClass='in' ID='txtNotice' runat="server" ></asp:TextBox></td>
            </tr>
            
            <tr>
                <td colspan='2' align="center">
                    <input type="button" id='btnSave1' value='保存' style="background-color:#296CB3; color:White ; width:50px; height:20px;" onclick ="save()" />
                    
                    
                </td>
            </tr>
        </table>
       <br />
   </div>
   
    <div>
       <table cellSpacing="0" cellPadding="0" border="0" align="center">
		    <tr>
		        <td style="background-color:White;padding-right: 10px; padding-left: 10px; padding-bottom: 10px; padding-top: 10px;">
		            <table cellSpacing="0" cellPadding="0" width="600" align="center" border="0" style="background-color:White;">
		                <tr>
		                    <td style="BORDER-RIGHT: #90b0de 1px solid; BORDER-TOP: #90b0de 1px solid; BORDER-LEFT: #90b0de 1px solid; BORDER-BOTTOM: #90b0de 1px solid">
		                        <table width="100%" cellSpacing="0" cellPadding="0" align="center" border="0">
		                            <tr height="30">
		                                <td style="border-bottom: #90b0de 1px solid; background-color: #ecf5ff; font-weight: bold; color: #004499; border-top-width: 1px; border-left-width: 1px; border-left-color: #90b0de; border-top-color: #90b0de; border-right-width: 1px; border-right-color: #90b0de;">&nbsp;&nbsp;&nbsp;<a href="tadmagazine.aspx">  <%=typename %> > (<span id='spanlab' runat="server" ></span>)</a></td>
		                            </tr>
		                        </table>
                             
                               
                                
                                
                                <div id="Div1" style="margin-top:10px;margin-bottom:0px;margin-left:10px;">
		                            <table cellSpacing="0" cellPadding="0" width="100%" border="0">
			                            <tr>
				                            <td height="24">
                                                <asp:button Width='50' id="btnAdd" runat="server" Height='20' Text="添加" CausesValidation="false" OnClientClick='clearin()' ForeColor="White" BackColor="#296CB3"  ></asp:button>
				                            </td>
			                            </tr>
		                            </table>
                                </div>
                                <div id="mnglist" style="margin-top:10px;margin-bottom:10px;margin-left:10px;margin-right:10px;">
                                    <asp:DataList RepeatColumns='2'  Font-Size='13px' ID="dlTable" runat="server" Width="100%" GridLines="None" OnItemCommand="dlTable_ItemCommand"  >
                                        <ItemTemplate>
                                            <table>
                                                <tr>
                                                    <td align="center"><a href='javascript:void(0)' style= "color:#004499" onclick ='javascript:opration="edit";inputbind("<%#Eval("issuecode") %>")'><%#Eval("covertitle") %></a>&nbsp;&nbsp;<asp:linkbutton id="lbDelete" ForeColor ='#004499' runat="server" CommandName="Del" CommandArgument='<%#Eval("issuecode") %>'><img border="0" src="./images/del.gif" alt="删除" onClick="javascript:{return confirm('删除操作不可恢复，确认吗？');}"></asp:linkbutton></td>
                                                    <td>出版编码:</td>
                                                    <td><%#Eval("issuecode") %></td>
                                                </tr>
                                                <tr>
                                                    <td rowspan='5' align="center"> <img id='imgcover' width='80' height='100' src='<%#Eval("cover") %>' /></td>
                                                    <td>期号:</td>
                                                    <td><%#Eval("issueno") %></td>
                                                </tr>
                                                <tr>
                                                    
                                                    <td>出版日期:</td>
                                                    <td><%#String.Format("{0:yyyy-MM-dd}", Eval("pubdate")) %></td>
                                                </tr>
                                                <tr>
                                                    
                                                    <td>总页数:</td>
                                                    <td><%#Eval("issuepages") %></td>
                                                </tr>
                                                <tr>
                                                    
                                                    <td>零售价:</td>
                                                    <td><%#Eval("price") %></td>
                                                </tr>
                                                <tr>
                                                    
                                                    <td>印刷数量:</td>
                                                    <td><%#Eval("printqty") %></td>
                                                </tr>
                                            </table>
                                        </ItemTemplate>
                                        <AlternatingItemStyle BackColor='#ECF5FF' />
                                        
                                    </asp:DataList>
                                     <%=pager%>
                                </div>
		                    </td>
		                </tr>
		            </table>
		        </td>
		    </tr>
		</table>
    </div>
    </form>
</body>
</html>